package com.yuyou.activity.group.service.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yuyou.activity.group.service.entity.ActivityGroupUser;
import com.yuyou.activity.group.service.mapper.ActivityGroupUserMapper;
import com.yuyou.activity.group.service.service.IActivityGroupUserService;
import com.yuyou.activity.util.util.Sequence;


@Service
public class ActivityGroupUserServiceImpl implements IActivityGroupUserService{


	@Autowired
	private ActivityGroupUserMapper activityGroupUserMapper;
	
	@Override
	public int deleteByPrimaryKey(Long id) {
		return activityGroupUserMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(ActivityGroupUser record) {
		if(record.getActivityGroupUserId()==null){
			record.setActivityGroupUserId(Sequence.getSequence().nextId());			
		}
		record.setCreateTime(new Date());
		return activityGroupUserMapper.insert(record);
	}

	@Override
	public ActivityGroupUser selectByPrimaryKey(Long id) {
		return activityGroupUserMapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKeySelective(ActivityGroupUser record) {
		return activityGroupUserMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public ActivityGroupUser findActiveGroupByPhone(String projectCode,String phone) {
		return activityGroupUserMapper.findActiveGroupByPhone(projectCode,phone);
	}

	@Override
	public ActivityGroupUser selectByCode7Phone(String projectCode, String phone) {
		return activityGroupUserMapper.selectByCode7Phone(projectCode, phone);
	}

	@Override
	public List<ActivityGroupUser> findByActGroId(Long activityGroupId) {
		return activityGroupUserMapper.findByActGroId(activityGroupId);
	}
	
	public List<ActivityGroupUser> findNotUpdateUser() {
		return activityGroupUserMapper.findNotUpdateUser();
	}

	@Override
	public void updateStatusByList(List<ActivityGroupUser> list) {
		activityGroupUserMapper.updateStatusByList(list);
	}

	@Override
	public void udateStatus(Long id, Integer status) {
		if(id != null){
			ActivityGroupUser user = new ActivityGroupUser();
			user.setActivityGroupUserId(id);
			user.setIsNotice(status);
			activityGroupUserMapper.updateByPrimaryKeySelective(user);
		}
	}

}
